#include<bits/stdc++.h>
#define pii pair<long long,long long>
#define mp make_pair
#define pb push_back
using namespace std;
long long T,n,m,l,v;
struct cr{
    long long s,v,de;
    inline void rd(){
        cin>>s>>v>>de;
    }
};
struct ab{
    int l,r;
};
cr a[100005];
long long b[100005];
ab c[100005];
bool cmp(ab x,ab y){
    return x.r<y.r;
}
bool pd(int x,int y){
    return (a[x].v*a[x].v+2*a[x].de*(b[y]-a[x].s))>v*v;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>T;
    while(T--){
        cin>>n>>m>>l>>v;
        for(int i=1;i<=n;i++){
            a[i].rd();
        }
        for(int i=1;i<=m;i++){
            cin>>b[i];
        }
        sort(b+1,b+m+1);
        b[m+1]=l+1;
        long long ans=0;
        for(int i=1;i<=n;i++){
            int t=lower_bound(b+1,b+m+2,a[i].s)-b;
            if(t==m+1){
                continue;
            }
            long long fr,to;
            if(a[i].de==0){
                if(a[i].v>v){
                    ans++;
                    fr=t,to=m;
                }
                else{
                    continue;
                }
            }
            if(a[i].de>0){
                if(!pd(i,m)){
                    continue;
                }
                ans++;
                long long mb=a[i].s+(v*v-a[i].v*a[i].v)/2/a[i].de;
                fr=upper_bound(b+t,b+m+1,mb)-b;
                to=m;
            }
            if(a[i].de<0){
                if(!pd(i,t)){
                    continue;
                }
                ans++;
                long long mb=a[i].s+(v*v-a[i].v*a[i].v)/(2*a[i].de)+(abs(v*v-a[i].v*a[i].v)%abs(2*a[i].de)!=0);
                fr=t;
                to=(lower_bound(b+t,b+m+1,mb)-1)-b;
            }
            c[ans].l=fr;
            c[ans].r=to;
        }
        sort(c+1,c+ans+1,cmp);
        long long la=0,ans1=0;
        for(int i=1;i<=ans;i++){
            while(i<=ans&&c[i].l<=la){
                i++;
            }
            if(i>ans)break;
            la=c[i].r;
            ans1++;
        }
        cout<<ans<<" "<<m-ans1<<"\n";
    }
    return 0;
}
